from selenium.webdriver.common.by import By
from utils.page import Page
class PageSell(Page):
    """
    首页界面
    """
    url = 'http://120.53.243.26:8009/api/userActivity/statistics/3'
    # 每年活跃度
    loc_yearly = (By.XPATH, '//*[@id="app"]/div[1]/div[2]/section/div/div[2]/div[1]/div[2]/div/label[3]')
    # 统计图
    yearly_data = (By.XPATH,'//*[@id="myChart"]/div/canvas')

    def __init__(self):
        super(PageSell, self).__init__()

    def click_reset(self):
        """
        点击每年
        """
        self.click(self.loc_yearly)

    @property
    def get_yearly_data(self):
        """
        获取每年活跃度信息
        """
        # todo
        data = []
        trs = self.finds(self.loc_yearly)
        if trs is None:
            return data

        for tr in trs:
            tds = tr.find_elements(By.TAG_NAME, 'td')
            items = []
            for td in tds:
                items.append(td.text)
            data.append(items)
        return data

